﻿using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Diagnostics;
using System.ComponentModel;

namespace ResourceMonitor._CPU
{
    public class ProcessGathering
    {
        // Initialize an instance to get all processes
        private Process[] processGet = Process.GetProcesses();

        // List gathering all the names of running processes.
        private List<string> _runningProccessNames = new List<string>();

        // List gathering all the names of noRunnig processes.
        private List<string> _noRunProcessNames = new List<string>();

        // List, gathering all processes in process.
        private List<string> _allProcessName = new List<string>(); 

        /// <summary>
        /// The method will go trough alll items in processGet
        /// and list it so we can get all processes on the local machine.
        /// </summary>
        /// <returns>Returns a list with all process names in string.</returns>
        private List<string> GetAllProcessNames()
        {
            foreach (var PROC in processGet)
            {
                _allProcessName.Add(PROC.ToString());
            }

            return _allProcessName;
        }

        /// <summary>
        /// The method will go trough alll items in processGet
        /// and list ONLY running items, so we can only get running
        /// processes on the local machine.
        /// </summary>
        /// <returns>Returns a list with all process names in string.</returns>
        private List<string> GetRunningProcessNames()
        {
            foreach (var PROC in processGet)
            {
                _runningProccessNames.Add(PROC.ToString());
            }

            return _runningProccessNames;
        }

        /// <summary>
        /// The method will go trough alll items in processGet
        /// and list ONLY non running items, so we can only get non running
        /// processes on the local machine.
        /// </summary>
        /// <returns>Returns a list with all process names in string.</returns>
        private List<string> GetNonRunningProcessNames()
        {
            foreach (var PROC in processGet)
            {
                _noRunProcessNames.Add(PROC.ToString());
            }

            return _noRunProcessNames;
        }

        public void PROC_Running()
        {
            GetRunningProcessNames();
        }

        public void PROC_NonRunning()
        {
            GetNonRunningProcessNames();
        }

        public void PROC_All()
        {
            GetAllProcessNames();
        }
    }
}
